
#! /bin/bash

CURRENT_PWD=$(cd "$(dirname "$0")";pwd)

CURRENT_ARCH=$(dpkg --print-architecture)

PACKAGE_NAME="org.gnome.gnome-terminal"
PACKAGE_VERSION="3.30.2"

# sudo apt-get update

sudo apt install libvte-2.91-dev libgtk-3-dev gsettings-desktop-schemas-dev libdconf-dev libpcre2-dev libnautilus-extension-dev libxml2-utils itstool -y

cd ..

# fixed automake version mismatch
# autoreconf

chmod +x configure

./configure --disable-search-provider --without-nautilus-extension --prefix=$CURRENT_PWD/debian/opt/apps/$PACKAGE_NAME/files

make -j8

make install

sed -i "/^Architecture:/cArchitecture: ${CURRENT_ARCH}" $CURRENT_PWD/debian/DEBIAN/control

cd $CURRENT_PWD

rm -rf $CURRENT_PWD/debian/opt/apps/$PACKAGE_NAME/files/lib/systemd/user/gnome-terminal-server.service

# mkdir -p $CURRENT_PWD/debian/opt/apps/$PACKAGE_NAME/files/bin
# cp ../src/lxterminal $CURRENT_PWD/debian/opt/apps/$PACKAGE_NAME/files/bin

# cp -rf $CURRENT_PWD/debian/opt/apps/$PACKAGE_NAME/files/share/applications/lxterminal.desktop $CURRENT_PWD/debian/opt/apps/$PACKAGE_NAME/entries/applications/$PACKAGE_NAME.desktop

# cp -rf $CURRENT_PWD/debian/opt/apps/$PACKAGE_NAME/files/share/icons $CURRENT_PWD/debian/opt/apps/$PACKAGE_NAME/entries

cp -rf $CURRENT_PWD/debian/opt/apps/$PACKAGE_NAME/files/share/locale $CURRENT_PWD/debian/opt/apps/$PACKAGE_NAME/entries

# Depends: libc6 (>= 2.27), libevent-2.1-7 (>= 2.1.8-stable), libtinfo6 (>= 6)
# dpkg-shlibdeps -O lxtask > shlibs.txt

# uos root-owner-group
dpkg-deb --root-owner-group  -b debian "${PACKAGE_NAME}_${PACKAGE_VERSION}_${CURRENT_ARCH}.deb"
